
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports _2bMatesSite.BO

Namespace _2bMatesSite
	''' <summary>
	''' Summary description for comments_confirmation.
	''' </summary>
	Public Partial Class comments_confirmation
		Inherits BaseWebPage
		Private usrID As Integer = -1
		Private grpID As Integer = -1
		Private isGroupMode As Boolean = False
		Private isConfirmed As String = "no"
		Protected htPageConstants As New Hashtable()

		Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
			' Put user code to initialize the page here
			' this.pageTemplate.PageTitle = PageTitles.COMMENTS_CONFIRMATION_PAGE;

			' init page from XML
			Me.initPageTitles(Constants.COMMENTS_CONFIRMATION, "", Form1, Nothing, htPageConstants)
			Me.initAdvertisements(Form1, Nothing)


			Try
				Dim usr As User
				If Request.Params("usr") = Nothing Then
					usr = LoggedUser
				Else
					usrID = Convert.ToInt32(Request.Params("usr"))
					usr = Users.GetUserByID(usrID)
				End If
				lblConfirmTextApprove.Visible = False

				' hide Message labels
				lblAddYourselfComments.Visible = False

				isConfirmed = Request.Params("conf")

				' init group
				If Request.Params(Constants.GROUP_PARAM) <> Nothing AndAlso Request.Params(Constants.GROUP_PARAM) <> "" Then
					isGroupMode = True
					grpID = Convert.ToInt32(Request.Params(Constants.GROUP_PARAM))
				End If

				If Not IsPostBack Then
					If isGroupMode = False AndAlso usr.ID = LoggedUser.ID Then
						lblConfirmText.Visible = False
						lblConfirmTextApprove.Visible = False
						btnBack.Visible = False
						lblAddYourselfComments.Visible = True
						litConfirmComment.Text = Me.GetPageConstText(htPageConstants, "CONST_MsgAddCommentsTo_TEXT")
						litConfirmComment.Text = litConfirmComment.Text.Replace("[PARAM]", usr.Name)
						trUserShortCut.Visible = False
					Else
						If isConfirmed = "yes" Then
							lblConfirmText.Visible = True
							lblConfirmText.Text = Me.GetPageConstText(htPageConstants, "CONST_MsgConfirm_TEXT")
						Else
							lblConfirmText.Visible = True
							If isGroupMode Then
								lblConfirmText.Text = Me.GetPageConstText(htPageConstants, "CONST_MsgNotMember_TEXT")
							Else
								hlInvite.Visible = True
								hlInvite.NavigateUrl = "../" + Constants.ADD_FRIEND_CONFIRMATION_PAGE + "?id=" + usr.ID + "&action=" + Constants.NEW_FRIENDSHIP
								lblConfirmText.Text = Me.GetPageConstText(htPageConstants, "CONST_MsgNotFriend_TEXT")
							End If
						End If

						If isGroupMode Then
							Dim grp As Group = Groups.GetGroupByID(grpID)
							If grp = Nothing Then
								Throw New Exception(Constants.ERROR_MESSAGE_MISSING_PARAMETERS)
							End If

							If Not grp.AutoApproveComments Then
								lblConfirmTextApprove.Visible = True
							End If

							trUserShortCut.Visible = False
						Else
							If Not usr.ApproveComments Then
								lblConfirmTextApprove.Visible = True
							End If

							If usr <> Nothing AndAlso usr.ID <> LoggedUser.ID Then
								ucMemberShortcut.UserID = usr.ID
							Else
								trUserShortCut.Visible = False
							End If
						End If
					End If
				End If
			Catch ex As Exception
				Dim s As String = ex.StackTrace
				Throw New Exception(Constants.ERROR_MESSAGE_MISSING_PARAMETERS)
			End Try

		End Sub

		#region Web Form Designer generated code
		Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
			'
			' CODEGEN: This call is required by the ASP.NET Web Form Designer.
			'
			InitializeComponent()
			MyBase.OnInit(e)
		End Sub

		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()

		End Sub
#End Region

		Protected Sub btnBack_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			If isGroupMode Then
				Response.Redirect(Constants.GROUP + "?" + Constants.GROUP_PARAM + "=" + grpID)
			Else
				Response.Redirect(Constants.MEMBERS + "?id=" + usrID)
			End If
		End Sub

		====================
        ' This public property was added by conversion wizard to allow the access of a protected, autogenerated member variable Form1.
		====================
        Public ReadOnly Property Form1() As System.Web.UI.HtmlControls.HtmlForm
            Get
                Return Migrated_Form1
            End Get
        End Property
        'set { Migrated_Form1 = value; }
    End Class
End Namespace






